import {
	Toast
} from 'vant';
export function submit(ref) {
	let obj = {}
	let arrList = []
	let isTrue
	if (ref !== undefined) {
		ref.forEach(item => {
			Object.assign(obj, item.pushData());
		})
		// 校验提示
		for (let i in obj) {
			if (obj[i].constructor === Object && obj[i].must === true) {
				Toast.fail(obj[i].text + '为必填！');
				break
			}
		}
		//遍历对象校验，把对象分成数组	
		for (let i in obj) {
			if (obj[i].constructor === Object && obj[i].must === false) {
				obj[i] = ''
			}
			if (obj[i].must === true) {
				arrList.push(obj[i])
			}
		}
		isTrue = arrList.every(function(item) {
			return item.constructor !== Object
		})
	} else {
		isTrue = true
	}
	return [isTrue, obj]
}
